package com.test.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.test.bean.QuartzTask;
import com.test.dao.QuartzTaskDao;

@Service("quartzTaskService")
@Transactional
public class QuartzTaskService {

	@Autowired
	private QuartzTaskDao quartzTaskDao;
	
	/**
	 * 获取任务
	 * @param QuartzTask
	 * @return
	 */
	public QuartzTask getQuartzTaskById(QuartzTask quartzTask){
		return  quartzTaskDao.getQuartzTaskById(quartzTask);
	}
	
	/**
	 * 添加任务
	 * @param QuartzTask
	 * @return
	 */
	public int addQuartzTask(QuartzTask quartzTask){
		return  quartzTaskDao.add(quartzTask);
	}
	
	/**
	 * 更新任务数据QuartzTask
	 * @param task
	 * @return
	 */
	public int updateQuartzTask(QuartzTask quartzTask){
		return  quartzTaskDao.updateQuartzTask(quartzTask);
	}
	
	/**
	 * 删除 QuartzTask
	 * @param task
	 * @return
	 */
	public int delQuartzTask(QuartzTask quartzTask){
		return  quartzTaskDao.delQuartzTask(quartzTask);
	}
	
	public Map<String,Object>getPage(String draw,String recordsFilteredSql,String recordsTotalSql,String sql){
		String recordsTotal= quartzTaskDao.getCountPage(recordsTotalSql);
		String recordsFiltered= quartzTaskDao.getCountPage(recordsFilteredSql);
		Map<String,Object>result=new HashMap<String,Object>();
		result.put("data",  quartzTaskDao.getPageAllQuartzTask(sql));
		result.put("recordsTotal", recordsTotal);
		result.put("recordsFiltered", recordsFiltered);
		result.put("draw",draw);
		return result;
	}
}
